/*   1:    */ package com.atomikos.icatch;
/*   2:    */ 
/*   3:    */ import java.io.PrintStream;
/*   4:    */ import java.util.ArrayList;
/*   5:    */ import java.util.List;
/*   6:    */ import java.util.Stack;
/*   7:    */ 
/*   8:    */ public class SysException
/*   9:    */   extends RuntimeException
/*  10:    */ {
/*  11:    */   private static final long serialVersionUID = -9183281406145817016L;
/*  12:    */   
/*  13:    */   private static void printNestedErrorStack(SysException e)
/*  14:    */   {
/*  15: 58 */     Stack errors = e.getErrors();
/*  16: 59 */     while ((errors != null) && (!errors.empty()))
/*  17:    */     {
/*  18: 60 */       System.err.println("Nested exception is: ");
/*  19: 61 */       Exception nxt = (Exception)errors.pop();
/*  20: 62 */       if ((nxt instanceof SysException))
/*  21:    */       {
/*  22: 63 */         SysException se = (SysException)nxt;
/*  23: 64 */         nxt.printStackTrace();
/*  24: 65 */         printNestedErrorStack(se);
/*  25:    */       }
/*  26:    */       else
/*  27:    */       {
/*  28: 68 */         nxt.printStackTrace();
/*  29:    */       }
/*  30:    */     }
/*  31:    */   }
/*  32:    */   
/*  33:    */   private static void addStackTraceElementsToList(StackTraceElement[] elements, List list)
/*  34:    */   {
/*  35: 76 */     for (int i = 0; i < elements.length; i++) {
/*  36: 77 */       list.add(elements[i]);
/*  37:    */     }
/*  38:    */   }
/*  39:    */   
/*  40: 82 */   private Stack myErrors = null;
/*  41:    */   
/*  42:    */   public SysException(String msg)
/*  43:    */   {
/*  44: 86 */     super(msg);
/*  45:    */   }
/*  46:    */   
/*  47:    */   public SysException(String msg, Stack nestedList)
/*  48:    */   {
/*  49: 90 */     super(msg);
/*  50: 91 */     this.myErrors = ((Stack)nestedList.clone());
/*  51:    */   }
/*  52:    */   
/*  53:    */   private void addStackTraceToList(List list)
/*  54:    */   {
/*  55: 96 */     StackTraceElement[] elements = super.getStackTrace();
/*  56: 97 */     addStackTraceElementsToList(elements, list);
/*  57: 98 */     Stack errors = getErrors();
/*  58: 99 */     while ((errors != null) && (!errors.empty()))
/*  59:    */     {
/*  60:100 */       Exception e = (Exception)errors.pop();
/*  61:102 */       if ((e instanceof SysException))
/*  62:    */       {
/*  63:103 */         SysException se = (SysException)e;
/*  64:104 */         se.addStackTraceToList(list);
/*  65:    */       }
/*  66:    */       else
/*  67:    */       {
/*  68:107 */         elements = e.getStackTrace();
/*  69:108 */         addStackTraceElementsToList(elements, list);
/*  70:    */       }
/*  71:    */     }
/*  72:    */   }
/*  73:    */   
/*  74:    */   public Stack getErrors()
/*  75:    */   {
/*  76:115 */     if (this.myErrors == null) {
/*  77:116 */       return null;
/*  78:    */     }
/*  79:118 */     return (Stack)this.myErrors.clone();
/*  80:    */   }
/*  81:    */   
/*  82:    */   public void printStackTrace()
/*  83:    */   {
/*  84:124 */     super.printStackTrace();
/*  85:125 */     printNestedErrorStack(this);
/*  86:    */   }
/*  87:    */   
/*  88:    */   public StackTraceElement[] getStackTrace()
/*  89:    */   {
/*  90:130 */     ArrayList elements = new ArrayList();
/*  91:    */     
/*  92:132 */     addStackTraceToList(elements);
/*  93:    */     
/*  94:134 */     return (StackTraceElement[])elements.toArray(new StackTraceElement[0]);
/*  95:    */   }
/*  96:    */ }


/* Location:           C:\myfile\mysoft\apache-maven-3.5.0-bin\apache-maven-3.5.0\myrep\com\atomikos\transactions-api\3.7.0\transactions-api-3.7.0.jar
 * Qualified Name:     com.atomikos.icatch.SysException
 * JD-Core Version:    0.7.0.1
 */